###############################################################
#
# Purpose: Makefile for "M-JPEG Streamer"
# Author.: Tom Stoeveken (TST)
# Version: 0.3
# License: GPL
#
###############################################################

CC ?= gcc


OTHER_HEADERS = ../../capture.h 

ifeq ($(CC),arm-linux-gcc)
CFLAGS += -O2 -Wall   -c -DLINUX -D_GNU_SOURCE -I/opt/FriendlyARM/xvid/include -fpic
CFLAGS_D = -Wall -g -c -DLINUX -D_GNU_SOURCE -I/opt/FriendlyARM/xvid/include -fpic
LDFLAGS += -lpthread -ldl -L/opt/FriendlyARM/xvid/lib -lxvidcore -shared -fpic
LDFLAGS_D = -lpthread -ldl -L/opt/FriendlyARM/xvid/lib -lxvidcore -shared -fpic
else
CFLAGS += -O2 -Wall   -c -DLINUX -D_GNU_SOURCE -fpic
CFLAGS_D = -Wall -g -c -DLINUX -D_GNU_SOURCE -fpic
LDFLAGS += -lpthread -ldl -lxvidcore -shared -fpic
LDFLAGS_D = -lpthread -ldl -lxvidcore -shared -fpic
endif

OBJECT = encode.o output_avi.o
OBJECT_D = encode_d.o output_avi_d.o

all: liboutput_avi.so

liboutput_avi.so: $(OBJECT)
	$(CC) $(LDFLAGS) $(OBJECT) -o $@

encode.o: encode.c encode.h
	$(CC) $(CFLAGS) $< -o $@

output_avi.o: output_avi.c output_avi.h
	$(CC) $(CFLAGS) $< -o $@
	
debug:liboutput_avi_d.so

liboutput_avi_d.so : $(OBJECT_D)
	$(CC) $(LDFLAGS_D) $< -o $@

encode_d.o: encode.c encode.h
	$(CC) $(CFLAGS_D) $< -o $@

output_avi_d.o: output_avi.c output_avi.h
	$(CC) $(CFLAGS_D) $< -o $@
clean:
	rm -f *.a *.o core *~ *.so *.lo


.PHONY: all clean debug
